﻿# CMakeList.txt : CMake project for user routine, include source and define
# project specific logic here.
cmake_minimum_required (VERSION 3.12)

## Enable compile command to ease indexing with e.g. clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

## Define the build type
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "Debug")
endif()

## compilers specific
if(MSVC)
    add_compile_definitions(_WIN32_WINNT=0x0A00)
    ### Enable Hot Reload for MSVC compilers if supported.
    if (POLICY CMP0141)
        cmake_policy(SET CMP0141 NEW)
        set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
    endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    if(WIN32)
        add_compile_definitions(_WIN32_WINNT=0x0A00)
    endif()
endif()

## Set the project name
set(CMAKE_PROJECT_NAME asio_stu)

## Core project settings
project (${CMAKE_PROJECT_NAME})
message("Build type: " ${CMAKE_BUILD_TYPE})

## language specific
## ---------------------------------------------------------------
    ### Setup compiler settings
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS ON)

    ### Enable CMake support for CXX languages
    enable_language(CXX)
## ---------------------------------------------------------------

# Add source to this project's executable.

## app sources begin
## ---------------------------------------------------------------
    add_executable (${CMAKE_PROJECT_NAME} "app/asio_stu.cpp" "app/asio_stu.h")
## ---------------------------------------------------------------
## app sources end

## middlewaves package sources begin
## ---------------------------------------------------------------
    ### ASIO C++ lib v1.30.2 [https://think-async.com/Asio/]
    ### +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
        ${PROJECT_SOURCE_DIR}/packages/third_party/asio/include
    )
    target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE 
        ASIO_STANDALONE
    )
    ### +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        ### Struc C++ lib [https://github.com/SlickZhang/struc]
    ### +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
        ${PROJECT_SOURCE_DIR}/packages/third_party/struc
    )
    ### +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

## ---------------------------------------------------------------
## middlewaves package sources end

## add other sources or lirbaries begin
## ---------------------------------------------------------------
    ### Link directories setup
    target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
        # Add user defined library search paths
    )

    ### Add sources to executable
    target_sources(${CMAKE_PROJECT_NAME} PRIVATE
        # Add user sources here
    )

    ### Add include paths
    target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
        # Add user defined include paths
    )

    ### Add project symbols (macros)
    target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
        # Add user defined symbols
    )

    ### Add linked libraries
if(WIN32)
    target_link_libraries(${CMAKE_PROJECT_NAME}
        # Add user defined libraries
        ws2_32
        mswsock
    )
else()
    target_link_libraries(${CMAKE_PROJECT_NAME}
        # Add user defined libraries
    )
endif()
## ---------------------------------------------------------------
## add other sources or lirbaries end


if (CMAKE_VERSION VERSION_GREATER 3.12)
  set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 20)
endif()

# TODO: Add tests and install targets if needed.
